import os 
import re
def listyoudir(level, path):  
    for i in os.listdir(path):  
        print '  '*(level+1) + i  
        if os.path.isdir(path + '\\' + i):  
            listyoudir(level+1, path + '\\' + i)
        else:
        	print i.endswith('.vm')
        	if i.endswith('.vm'):
        		fp = open(path + '\\' + i,"r")
        		wp = open(path + '\\' + 'x.vm','w')
        		data = fp.read().decode("gbk")
        		data = re.sub(r"\$!vmutil.escapeHtml\((.*?)\)",r"\1",data)
        		wp.write(data.encode("gbk"))
        	
        	           
rootpath = os.path.dirname("Z:\\zeus\\templates\\zeus\\chs")
print rootpath  
listyoudir(0, rootpath) 